package com.ruoyi.common.domain.light;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ruoyi.common.core.domain.BaseEntity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.annotation.TableId;
import com.ruoyi.common.core.domain.entity.SysRole;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * 安灯配置 - 异常类型表 lit_config_err
 *
 * @author ruoyi
 * @date 2022-02-14
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class LitConfigErr extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 故障id
     */
    @TableId
    private Long errId;
    /**
     * 故障父id
     */
    private Long parentId;
    /**
     * 祖级列表
     */
    private String ancestors;
    /**
     * 故障名称
     */
    private String errName;
    /**
     * 显示顺序
     */
    private Integer orderNum;

    /**
     * 删除标志（0代表存在 1代表删除）
     */
    @TableLogic
    private Integer deleted;
    /**
     * 异常类别等级
     */
    private Integer errLv;

    /**
     //     * 角色组
     //     */
    @TableField(exist = false)
    private List<Long> roleIdList;
    @TableField(exist = false)
    @JsonIgnore
    private List<SysRole> roleList;


//    /**
//     * 角色组
//     */
//    @TableField(exist = false)
//    private List<Long> initRoleIdList;
//    @TableField(exist = false)
//    @JsonIgnore
//    private List<SysRole> initRoleList;


//    /**
//     * 角色组
//     */
//    @TableField(exist = false)
//    private List<Long> signRoleIdList;
//    @TableField(exist = false)
//    @JsonIgnore
//    private List<SysRole> signRoleList;


//    /**
//     * 角色组
//     */
//    @TableField(exist = false)
//    private List<Long> liftRoleIdList;
//    @TableField(exist = false)
//    @JsonIgnore
//    private List<SysRole> liftRoleList;

//
//    /**
//     * 角色组
//     */
//    @TableField(exist = false)
//    private List<Long> verifyRoleIdList;
//    @TableField(exist = false)
//    @JsonIgnore
//    private List<SysRole> verifyRoleList;


    /**
     * 子菜单
     */
    @TableField(exist = false)
    private List<LitConfigErr> children = new ArrayList<>();


    public List<Long> getRoleIdList() {
        if (roleIdList == null)
            roleIdList = new ArrayList<>();
        return roleIdList;
    }

    public List<SysRole> getRoleList() {
        if (roleList == null)
            roleList = new ArrayList<>();
        return roleList;
    }

    public String getRoleNames() {
        if (getRoleList().size() == 0) {
            return "";
        }
        return getRoleList().stream().filter(Objects::nonNull).map(SysRole::getRoleName).collect(Collectors.joining(","));
    }


//    public List<Long> getInitRoleIdList() {
//        if (initRoleIdList == null)
//            initRoleIdList = new ArrayList<>();
//        return initRoleIdList;
//    }

//    public List<Long> getSignRoleIdList() {
//        if (signRoleIdList == null)
//            signRoleIdList = new ArrayList<>();
//        return signRoleIdList;
//    }
//
//    public List<Long> getLiftRoleIdList() {
//        if (liftRoleIdList == null)
//            liftRoleIdList = new ArrayList<>();
//        return liftRoleIdList;
//    }
//
//    public List<Long> getVerifyRoleIdList() {
//        if (verifyRoleIdList == null)
//            verifyRoleIdList = new ArrayList<>();
//        return verifyRoleIdList;
//    }
//
//    public List<SysRole> getInitRoleList() {
//        if (initRoleList == null)
//            initRoleList = new ArrayList<>();
//        return initRoleList;
//    }
//
//    public List<SysRole> getSignRoleList() {
//        if (signRoleList == null)
//            signRoleList = new ArrayList<>();
//        return signRoleList;
//    }
//
//    public List<SysRole> getLiftRoleList() {
//        if (liftRoleList == null)
//            liftRoleList = new ArrayList<>();
//        return liftRoleList;
//    }
//
//    public List<SysRole> getVerifyRoleList() {
//        if (verifyRoleList == null)
//            verifyRoleList = new ArrayList<>();
//        return verifyRoleList;
//    }

//    public String getInitRoleNames() {
//        if (getInitRoleList().size() == 0) {
//            return "";
//        }
//        return getInitRoleList().stream().filter(Objects::nonNull).map(SysRole::getRoleName).collect(Collectors.joining(","));
//    }

//    public String getSignRoleNames() {
//        if (getSignRoleList().size() == 0) {
//            return "";
//        }
//        return getSignRoleList().stream().filter(Objects::nonNull).map(SysRole::getRoleName).collect(Collectors.joining(","));
//    }
//
//    public String getLiftRoleNames() {
//        if (getLiftRoleList().size() == 0) {
//            return "";
//        }
//        return getLiftRoleList().stream().filter(Objects::nonNull).map(SysRole::getRoleName).collect(Collectors.joining(","));
//    }
//
//    public String getVerifyRoleNames() {
//        if (getVerifyRoleList().size() == 0) {
//            return "";
//        }
//        return getVerifyRoleList().stream().filter(Objects::nonNull).map(SysRole::getRoleName).collect(Collectors.joining(","));
//    }
}